<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.wlcorp.forcazamis.sys.util.AppConstant" %>
<%@ page import="com.wlcorp.forcazamis.domain.storageassign.StorageAssign" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.wlcorp.forcazamis.domain.baseinfo.Depot" %>

<%
	StorageAssign storageAssign = (StorageAssign)request.getAttribute("storageAssign");
	List depotList = (List)request.getAttribute("depotList");
%>
<html>
<head>
	<title>样品调拨单信息更新</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0">
	<link href="${pageContext.request.contextPath}/css/css.css" rel=stylesheet>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/button_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/form_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/table_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/pagetitle_css.css" type="text/css">
	<script language="javascript" src="${pageContext.request.contextPath}/script/validator.js"></script>
	<script language="javascript" src="${pageContext.request.contextPath}/script/calendartime.js"></script>
	<script language="javascript" src="${pageContext.request.contextPath}/script/ajax.js"></script>
	<script type="text/javascript">
		function doSave(){
			if(!fieldIsNotEmpty(document.forms["storageAssignForm"].assignToDepotId)){
				return;
			}
			if(!fieldIsNotEmpty(document.forms["storageAssignForm"].assignToStaffId)){
				return;
			}
			document.forms["storageAssignForm"].submit();
		}
		function goback(){
			window.location = "${pageContext.request.contextPath}/storageassign/storageAssignManager.do?method=storageAssignManager";
		}
		function storageDetail(storageAssignId){
			window.location = "${pageContext.request.contextPath}/storageassign/storageAssignManager.do?method=getStorageAssignDetail&storageAssignId=" + storageAssignId;
		}
		function assignToDepotChange(depotId){
			var sUrl = "${pageContext.request.contextPath}/baseinfo/depotManager.do?method=getStaffSelectList&depotId=" + depotId;
			ajaxRead(sUrl,function(obj){
				var selectObj = document.forms["storageAssignForm"].assignToStaffId;
				selectObj.options.length = 0;
				if("" == obj.responseText){
					return;
				}
				var resultXML = obj.responseXML;
				var elementList = resultXML.getElementsByTagName("element");
				for(i = 0;i < elementList.length;i++){
                  var value = elementList[i].getElementsByTagName("staffId")[0].firstChild.data;
                  var text = elementList[i].getElementsByTagName("staffName")[0].firstChild.data;
                  var oOption = document.createElement("OPTION");
                  oOption.value = value;
                  oOption.text = text;
                  selectObj.add(oOption);
                }
                <%
                	if(null != storageAssign.getAssignToStaff()){
                %>
                selectObj.value = "<%=storageAssign.getAssignToStaff().getStaffId()%>";
                <%}%>
			});
		}
	</script>
</head>
<body onload="javascript:assignToDepotChange(document.forms['storageAssignForm'].assignToDepotId.value)">
<form name="storageAssignForm" method="POST" action="${pageContext.request.contextPath}/storageassign/storageAssignManager.do?method=modifyStorageAssign">
<input type="hidden" name="storageAssignId" value="${storageAssign.storageAssignId}"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="30">
	<tr> 
	  <td width="22" class="page_titlebar_head">&nbsp;</td>
	  <td class="page_titlebar_bg" width="981">样品调拨单编辑</td>
	</tr>
</table>
<center>
<%
	if(null == storageAssign.getState() || AppConstant.ASSIGN_STATE_SUBMITED == storageAssign.getState().intValue()){
%>
<table width="700" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="table_bgcolor">
      <tr> 
        <td align="right" valign="middle"> 
          <input class=button_save type=button name=save value="      保存" style="font-size:9pt" onClick="javascript:doSave()" id="btn_submit">
          <input class=button_reset name=qqq type=reset value="      恢复" style="font-size:9pt" id="btn_reset">
          <input type=button name=rst class=button_recovery value="     返回" style="font-size:9pt" onClick="javascript:history.go(-1);" id="btn_recovery">
        </td>
      </tr>
</table>
<%}%>
<table width="700" class=InputFrameMain cellspacing="0" cellpadding="0" border="0">
      <tr> 
        <td colspan="4" class="table_unfold_titlebar_small_bg">&nbsp;&nbsp;<b>样品调拨单</b></td>
      </tr>  
      <tr class="InputFrameLine">
  		<td class="table_label" width="20%" id="assignFromDepotId_TEXT">调出仓库</td>
		<td width="30%">&nbsp;<select name="assignFromDepotId" style="width:100px">
			<%
				for(Iterator iter = depotList.iterator();iter.hasNext();){
					Depot depot = (Depot)iter.next();
			%>
			<option value="<%=depot.getDepotId()%>" <%if(null != storageAssign.getAssignFromDepot() && storageAssign.getAssignFromDepot().getDepotId().equals(depot.getDepotId())){out.print("selected");}%>><%=depot.getDepotName()%></option>
			<%}%>
		</select>
		</td>
        <td class="table_label" width="20%" id="submiterId_TEXT">调拨人</td>
		<td width="30%">&nbsp;<input class="input" type="text" name="submiterId" value="${storageAssign.submiter.staffName}" style="width:150px" disabled/>
		</td>
  </tr>
  <tr class="InputFrameLine">
  		<td class="table_label" width="20%" id="assignToDepotId_TEXT">调入仓库</td>
		<td width="30%">&nbsp;<select name="assignToDepotId" style="width:100px" onchange="assignToDepotChange(this.value)">
			<option value="">--选择--</option>
			<%
				for(Iterator iter = depotList.iterator();iter.hasNext();){
					Depot depot = (Depot)iter.next();
			%>
			<option value="<%=depot.getDepotId()%>" <%if(null != storageAssign.getAssignToDepot() && storageAssign.getAssignToDepot().getDepotId().equals(depot.getDepotId())){out.print("selected");}%>><%=depot.getDepotName()%></option>
			<%}%>
		</select>
		</td>
        <td class="table_label" width="20%" id="assignToStaffId_TEXT">指定接收人</td>
		<td width="30%">&nbsp;<select name="assignToStaffId" style="width:100px">
		</select>
		</td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" width="20%" id="assignDate_TEXT">调出时间</td>
		<td width="80%" colspan="3">&nbsp;<input class="input" type="text" name="assignDate" value="${storageAssign.assignDate}" style="width:150px" disabled/>
		</td>
  </tr>
  <tr class="InputFrameLine">
        <td class="table_label" width="20%" id="memo_TEXT">备注</td>
		<td width="80%" colspan="3">&nbsp;<textarea id="memo" name="memo" cols="40" rows="5" style="width:400px">${storageAssign.memo}</textarea>
		</td>
  </tr>
  <tr class="InputFrameLine">
  	<td width="100%" colspan="4" align="center">
  		<input type="button" class="button_common_5" name="storageDetailButton" value="调拨单样品细节" onclick="javascript:storageDetail('${storageAssign.storageAssignId}')" <%if(null == storageAssign.getStorageAssignId()){out.print("disabled");}%>/>
  	</td>
  </tr>
</table>
</center>
</form>
${message}
</body>
</html>
